home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 735 / 735.xpi / chrome / answers.jar / content / webtip1.js < prev   
Text File  |  2010-02-07  |  66KB  |  1,829 lines

  1. /*----------------------------------------------------------------------------\
  2. |                               JSBalloon                                     |
  3. |-----------------------------------------------------------------------------|
  4. |                   Created by Arkady (Alex) Lesniara                         |
  5. |                           (arkady@lesniara.com)                             |
  6. |-----------------------------------------------------------------------------|
  7. |                  Copyright (c) 2005 Arkady Lesniara                         |
  8. |-----------------------------------------------------------------------------|
  9. | This software is provided "as is", without warranty of any kind, express or |
  10. | implied, including  but not limited  to the warranties of  merchantability, |
  11. | fitness for a particular purpose and noninfringement. In no event shall the |
  12. | authors or  copyright  holders be  liable for any claim,  damages or  other |
  13. | liability, whether  in an  action of  contract, tort  or otherwise, arising |
  14. | from,  out of  or in  connection with  the software or  the  use  or  other |
  15. | dealings in the software.                                                   |
  16. \----------------------------------------------------------------------------*/
  17.  
  18. // create the base ANSW object if it does not exist.
  19.  if (typeof ANSW=="undefined") {
  20.      ANSW = new Object();
  21.  }
  22. ANSW.alert= function(msg){
  23. //    alert(msg)
  24. };
  25. ANSW.console = function(msg){
  26.     //if(window.console)  window.console.log(msg);
  27. };
  28. ANSW.Init = function(nafid,cobrand)
  29. {
  30.     ANSW.nafid = nafid;
  31.     ANSW.cobrand = cobrand;
  32. };
  33.  
  34. /*    Class: ANSW.Balloon
  35.     Provides a flexible, encapsulated way to implement a passive feedback mechanism
  36.     in a DHTML environment. Define and initialize this object globally, otherwise it will create a new instance
  37.     each time you call it's constructor. Set up the object with an object array passed to the constructor or, once instantiated,
  38.     with properties. See <Usage> for more.
  39. */
  40. ANSW.Balloon = function()
  41. {
  42.     var oldkeyup;
  43.     this.oldkeyup = oldkeyup;
  44.     var oldmousedown;
  45.     this.oldmousedown = oldmousedown;
  46.     var oldmouseup;
  47.     this.oldmouseup = oldmouseup;
  48.     var oldcontextmenu;
  49.     this.oldcontextmenu = oldcontextmenu;
  50.     var oldmousemove;
  51.     this.oldmousemove = oldmousemove;
  52.  
  53.     var tmrIFrameGone;
  54.     this.tmrIFrameGone = tmrIFrameGone;
  55.  
  56.     var blbWidth=200;
  57.     this.blbWidth =  blbWidth;
  58.     this.showCloseBox=false;
  59.  
  60.    this.initBalloon = function()
  61.     {
  62.         if(arguments.length>0)
  63.         {
  64.             var oArg=arguments[0];
  65.  
  66.             if(oArg.width!=null)
  67.             {
  68.                 this.blbWidth=oArg.width;
  69.             }
  70.             this.width=this.blbWidth;
  71.         }
  72.     };
  73.  
  74.     var childID;
  75.     this.childID= childID;
  76.  
  77.  
  78.     // Public Methods
  79.     this.Show=Show;
  80.     this.Hide=Hide;
  81.     this.isVisible=isVisible;
  82.  
  83.     /*    Function: Show
  84.             Makes the instantiated balloon appear.
  85.  
  86.         Balloon content note:
  87.             Because SELECT objects are what's known as windowed controles
  88.             they need to be hidden when balloons are shown, otherwise they will always be on top
  89.             (they ignore zIndex attribute). It is normally done automatically by this control.
  90.             Sometimes, however, you may want to place a drop-down inside the balloon itself.
  91.             To override this default behaviour add an balloonMember expando attirbute to
  92.             the SELECT you are placing withing.
  93.  
  94.             - e.g. <SELECT id=select1 name=select1 balloonMember=true>
  95.  
  96.         Syntax:
  97.             (start code)
  98.             object.Show({[title:vTitle]
  99.                          [,message:vMessage]
  100.                          [,footer:vFooter]
  101.                          [,top:vTop]
  102.                          [,left:vLeft]
  103.                          [,anchor:vAnchor]
  104.                          [,icon:vIcon]
  105.                          [,query:vQuery]
  106.                          });
  107.             (end)
  108.  
  109.         Possible Values:
  110.             vTitle - *string* Optional title text for the balloon.
  111.             vMessage - *string* Optional. Message body for the balloon.
  112.             vFooter - *string* Optional. Test displayed at the bottom of the balloon on a separate line.
  113.             vTop - *integer* Optional. Offset from the top of the screen or top of an anchor.
  114.             vLeft - *integer* Optional. Offset from the left of the screen or left of an anchor.
  115.             vAnchor - *object* Optional. Reference to the object that the balloon should use as reference for location.
  116.             vIcon - *string* Optional. Possible icon values may include one of the values below (case sensitive):
  117.                  - Exclaim - pre-defined, triangle with an exclamation point.
  118.                  - Stop - pre-defined, red circle with a white x inside.
  119.                  - Info - pre-defined, white balloon with a letter "i" inside *Default*
  120.                  - Help - a question mark inside a blue circle.
  121.                  - a relative path to a custom icon.
  122.            vQuery - *query string*
  123.  
  124.         Examples:
  125.  
  126.             - balloonObj.Show({title:'JavaScript Balloon Example',message:'This is an example of a JSBalloon object. It\'s primary application is to provide a modeless feedback to DHTML applications.',anchor:tableCellObj, icon:'Info'});
  127.             - balloonObj1.Show({title:'JavaScript Balloon Example',message:'This is an example of a JSBalloon object. It\'s primary application is to provide a modeless feedback to DHTML applications.',anchor:tableCellObj});
  128.             - balloonObj2.Show({message:'This is an example of a JSBalloon object. It\'s primary application is to provide a modeless feedback to DHTML applications. ',anchor:tableCellObj});
  129.  
  130.     */
  131.  
  132.     function Show()
  133.     {
  134.         var title;
  135.         var btop=0, bleft=0;
  136.         var atop=0, aleft=0;
  137.         var anchor;
  138.         var direction='SE';
  139.         var query ='';
  140.         var nafid='';
  141.         var cobrand='';
  142.         var nohook = false;
  143.         var parent = null;
  144.         var ads=0;
  145.         var mydoc= ANSW.isFirefoxExtension ? window.content.document : document;
  146.         blbWidth=String(this.width) + "px";
  147.  
  148.         // Updates
  149.  
  150.         if(Show.arguments.length>0)
  151.         {
  152.             var oArg=Show.arguments[0];
  153.  
  154.             if(oArg.title!=null)
  155.             {
  156.                 title=oArg.title;
  157.             }
  158.  
  159.             if(oArg.top!=null)
  160.             {
  161.                 btop=oArg.top;
  162.             }
  163.  
  164.             if(oArg.left!=null)
  165.             {
  166.                 bleft=oArg.left;
  167.             }
  168.  
  169.             if(oArg.anchor!=null)
  170.             {
  171.                 anchor=oArg.anchor;
  172.                 atop=getTop(anchor);
  173.                 aleft=getLeft(anchor);
  174.             }
  175.             if(oArg.query!=null)
  176.             {
  177.                 query=oArg.query;
  178.             }
  179.              if(oArg.nafid!=null)
  180.             {
  181.                 nafid=oArg.nafid;
  182.             }
  183.             if(oArg.cobrand!=null)
  184.             {
  185.                 cobrand=oArg.cobrand;
  186.             }
  187.             if(oArg.nohook!=null)
  188.             {
  189.                 nohook= true;
  190.             }
  191.             if(oArg.parent!=null)
  192.             {
  193.                 parent= oArg.parent;
  194.             }
  195.             if(oArg.ads!=null)
  196.             {
  197.                 ads= oArg.ads;
  198.             }
  199.         }
  200.         if (parent)
  201.         {
  202.             mydoc = parent.parentNode;
  203.             mydoc= mydoc.parentNode;
  204.             ANSW.doc = mydoc;
  205.         }
  206.         var formerBalloon = mydoc.getElementById("AnswersBalloon");
  207.         if (ANSW.doc)
  208.             formerBalloon = ANSW.doc.getElementById("AnswersBalloon");
  209.         ANSW.alert(" ANSW.doc= "+ANSW.doc);
  210.         ANSW.alert(" formerBalloon= "+formerBalloon);
  211.         ANSW.alert("btop = " + btop);
  212.         if (bleft == -1 && btop == -1)
  213.         {
  214.             var answertip = ANSW.doc.getElementById("Answertip");
  215.             answertip.innerHTML= '<DIV class="answering" >Answering...</DIV>';
  216.             var answerads = ANSW.doc.getElementById("AnswersAds");
  217.             var local ="";
  218.             if (this.answersURL.indexOf(":8080")!= -1)
  219.                 local = "/answers";
  220.             if (answerads !=null)
  221.             {
  222.                 if (typeof cobrand != "undefined" && cobrand!=null)
  223.                 {
  224.                     answerads.src= this.answersURL + local + '/main/tip2.jsp?s=' + query +"&wt=1"+"&cobrand="+cobrand;
  225.                 }
  226.                 if (typeof nafid != "undefined" && nafid!=null)
  227.                 {
  228.                         answerads.src +="&nafid="+nafid;
  229.                 }
  230.                 if (ads>0)
  231.                         answerads.src ="";
  232.             }
  233.             return;
  234.         }
  235.         else
  236.         {
  237.             this.balloonDIV = mydoc.createElement("DIV");
  238.             this.balloonDIV.id="AnswersBalloon";
  239.             this.balloonDIV.style.width=String(blbWidth);
  240.             this.balloonDIV.style.position="absolute";
  241.             this.balloonDIV.style.visibility="hidden";
  242.             this.balloonDIV.style.zIndex=99999;
  243.             this.balloonDIV.style.textAlign="left";
  244.         }
  245.         // Figure out the best direction for the pointer
  246.         // Assume SE
  247.         var ret=this.balloonInfrastructure(balloonBody(    title,
  248.                                                     this.showCloseBox,cobrand),this.JSBalloonPath,direction,query,nafid,cobrand,ads);
  249.         // check if the object is already initialized
  250.         if(formerBalloon)
  251.         {
  252.             ANSW.b5.Hide();
  253.             this.childID=ANSW.doc?ANSW.doc.body.replaceChild(this.balloonDIV,formerBalloon):mydoc.body.replaceChild(this.balloonDIV,formerBalloon);
  254.             if (this.ifrlayer)
  255.                 this.ifrlayer.replace(this.balloonDIV);
  256.         }
  257.         else
  258.         {
  259.             ANSW.alert("parent= "+parent);
  260.             if (parent)
  261.                 this.childID=parent.appendChild(this.balloonDIV);
  262.             else
  263.                 this.childID=mydoc.body.appendChild(this.balloonDIV);
  264.             if (this.ifrlayer)
  265.                 this.ifrlayer.make(this.balloonDIV);
  266.         }
  267.         this.balloonDIV.innerHTML=ret;
  268.  
  269.         var balloonLeft;
  270.         var balloonTop;
  271.         if(anchor!=null)
  272.         {
  273.             balloonLeft = aleft+bleft;
  274.             balloonTop = atop-this.balloonDIV.offsetHeight+btop; // problem here first time with firefox 1.5
  275.         }
  276.         else
  277.         {
  278.             balloonLeft = bleft;
  279.             balloonTop = btop -this.balloonDIV.offsetHeight ;
  280.         }
  281.         ANSW.alert("balloonLeft= " + balloonLeft + " balloonTop= " + balloonTop);
  282.         var bAdjustedLeft=balloonLeft; //parseInt(balloonDIV.style.left, 10);
  283.         var showSE;
  284.         ANSW.alert("bAdjustedLeft= " + bAdjustedLeft);
  285.         ANSW.alert("balloonDIV.offsetWidth= " + this.balloonDIV.offsetWidth);
  286.         ANSW.alert("balloonDIV.offsetHeight= " + this.balloonDIV.offsetHeight);
  287.         var clientWidth;
  288.         var clientHeight;
  289.         var scrollLeft;
  290.         var scrollTop;
  291.         if (self.innerHeight) // all except Explorer
  292.         {
  293.             clientWidth = self.innerWidth;
  294.             clientHeight = self.innerHeight;
  295.         }
  296.         else if (mydoc.documentElement && mydoc.documentElement.clientHeight)
  297.             // Explorer 6 Strict Mode
  298.         {
  299.             clientWidth = mydoc.documentElement.clientWidth;
  300.             clientHeight = mydoc.documentElement.clientHeight;
  301.         }
  302.         else if (mydoc.body) // other Explorers
  303.         {
  304.             clientWidth = mydoc.body.clientWidth;
  305.             clientHeight = mydoc.body.clientHeight;
  306.         }
  307.  
  308.         if (self.pageYOffset) // all except Explorer
  309.         {
  310.             scrollLeft = self.pageXOffset;
  311.             scrollTop = self.pageYOffset;
  312.         }
  313.         else if (mydoc.documentElement && mydoc.documentElement.scrollTop)
  314.             // Explorer 6 Strict
  315.         {
  316.             scrollLeft = mydoc.documentElement.scrollLeft;
  317.         scrollTop = mydoc.documentElement.scrollTop;
  318.         }
  319.         else if (mydoc.body) // all other Explorers
  320.         {
  321.             scrollLeft = mydoc.body.scrollLeft;
  322.             scrollTop= mydoc.body.scrollTop;
  323.         }
  324.  
  325.         ANSW.alert("clientWidth= " + clientWidth );
  326.         ANSW.alert("clientHeight= " + clientHeight );
  327.         ANSW.alert("scrollLeft= " + scrollLeft );
  328.         ANSW.alert("scrollTop= " + scrollTop );
  329.         var check = bAdjustedLeft - 0 + this.balloonDIV.offsetWidth - scrollLeft + 20;
  330.         ANSW.alert("check= " + check);
  331.         if(clientWidth - 0 < check - 0)
  332.         {
  333.             direction='SW';
  334.             ANSW.alert("SW");
  335.             ret=this.balloonInfrastructure(balloonBody(    title,
  336.                                                     this.showCloseBox,cobrand),this.JSBalloonPath, direction,query,nafid,cobrand,ads);
  337.             this.balloonDIV.innerHTML=ret;
  338.  
  339.             balloonLeft = bAdjustedLeft-this.balloonDIV.offsetWidth;
  340.             ANSW.alert("balloonLeft = " + balloonLeft);
  341.             showSE=false;
  342.         }
  343.         else
  344.         {
  345.  
  346.             direction='SE';
  347.             showSE=true;
  348.         }
  349.  
  350.         ANSW.alert("balloonLeft= " + balloonLeft + " balloonTop= " + balloonTop);
  351.         if(balloonTop < scrollTop)
  352.         {
  353.  
  354.             if(showSE)
  355.             {
  356.                 direction='NE';
  357.                 ret=this.balloonInfrastructure(balloonBody(    title,
  358.                                                     this.showCloseBox,cobrand), this.JSBalloonPath,direction,query,nafid,cobrand,ads);
  359.                 this.balloonDIV.innerHTML=ret;
  360.             }
  361.             else
  362.             {
  363.                 direction='NW';
  364.                 ret=this.balloonInfrastructure(balloonBody(    title,
  365.                                                     this.showCloseBox,cobrand), this.JSBalloonPath, direction,query,nafid,cobrand,ads);
  366.                 this.balloonDIV.innerHTML=ret;
  367.  
  368.             }
  369.             balloonTop += this.balloonDIV.offsetHeight;
  370.  
  371.             if(anchor!=null)
  372.             {
  373.                 balloonTop += anchor.offsetHeight;
  374.                 if (document.all && !this.isOpera) // only for  IE
  375.                 {
  376.                     balloonTop += this.balloonDIV.offsetParent.scrollTop;
  377.                 }
  378.             }
  379.         }
  380.         else
  381.         {
  382.             ANSW.alert("1left1= " + balloonLeft + " top1= " + balloonTop);
  383.         }
  384.         if(this.showCloseBox)
  385.         {
  386.             if(direction=='SE' || direction=='SW')
  387.             {
  388.                 btnClose=this.balloonDIV.children[0].children[0].children[1].children[0].children[0].children[0].children[0].children[2].children[0];
  389.             }
  390.             else
  391.             {
  392.                 btnClose=this.balloonDIV.children[0].children[0].children[2].children[0].children[0].children[0].children[0].children[2].children[0];
  393.             }
  394.             btnClose.onclick=this.Hide;
  395.         }
  396.         ANSW.alert("3balloonLeft= " + balloonLeft + " balloonTop= " + balloonTop);
  397.         // Adjust all scrollers except for opera
  398.         if (!this.isOpera)
  399.         {
  400.             if (anchor)
  401.             {
  402.                 var scrollOffsets=ScrollOffsets(anchor);
  403.                 balloonTop -= scrollOffsets[0];
  404.                 balloonLeft -= scrollOffsets[1];
  405.  
  406.             }
  407.         }
  408.         if (balloonLeft<0 || balloonTop<0 || (btop + this.balloonDIV.offsetHeight - scrollTop - clientHeight)>0 && direction.indexOf('N')==0)
  409.         {
  410.             var athook = ANSW.doc ? ANSW.doc.getElementById("AnswerTipHook") : mydoc.getElementById("AnswerTipHook");
  411.             if (athook)
  412.             {
  413.                 athook.style.visibility='hidden';
  414.             }
  415.             balloonTop = scrollTop;
  416.             if (clientWidth<=1025)   // center the Answertip
  417.                 balloonLeft = clientWidth/2 -this.balloonDIV.offsetWidth/2+scrollLeft;
  418.             else
  419.              {
  420.                 if (direction=='NE' || direction=='SE')
  421.                     balloonLeft += 50;
  422.                 else
  423.                    balloonLeft -= 50;
  424.              }
  425.         }
  426.         else
  427.         {
  428.             if (ANSW.isFirefoxExtension)
  429.             {
  430.                 if (direction.indexOf("E")>0) // East correction -20 West correction +20
  431.                     balloonLeft -=20;
  432.                 else
  433.                     balloonLeft +=20;
  434.                 if(direction=='SE' || direction=='SW')
  435.                     balloonTop -=5;
  436.                 else
  437.                     balloonTop +=5;
  438.             }
  439.              else
  440.             {
  441.                 if(direction=='NW' || direction=='SW')
  442.                     balloonLeft +=15;
  443.                 if(direction=='NW' || direction=='NE')
  444.                     balloonTop +=10;
  445.             }
  446.         }
  447.         if(nohook)
  448.         {
  449.             var athook = ANSW.doc ? ANSW.doc.getElementById("AnswerTipHook") : mydoc.getElementById("AnswerTipHook");
  450.             if (athook)
  451.             {
  452.                 athook.style.visibility='hidden';
  453.             }
  454.         }
  455.  
  456.         ANSW.alert("leftb= " + this.balloonDIV.style.left + " topb= " + this.balloonDIV.style.top);
  457.         ANSW.alert("4balloonLeft= " + balloonLeft + " balloonTop= " + balloonTop);
  458.         ANSW.alert("4this.balloonDIV.offsetHeight= " + this.balloonDIV.offsetHeight + " top= " + top + " mydoc.body.clientHeight= " + mydoc.body.clientHeight);
  459.  
  460.         this.balloonDIV.style.top=balloonTop+"px";
  461.         this.balloonDIV.style.left=balloonLeft+"px";
  462.         ANSW.alert("lefta= " + this.balloonDIV.style.left + " topa= " + this.balloonDIV.style.top);
  463.         ANSW.alert("direction=" + direction);
  464.         this.balloonDIV.direction=direction;
  465.         // kludge for bug in FF-Mac - scrollbar stays when window hidden
  466.            var answertip = ANSW.doc ? ANSW.doc.getElementById("Answertip") : mydoc.getElementById("Answertip");
  467.         if (answertip)
  468.             answertip.style.overflow="auto";
  469.         // Hide any overlapping selects
  470.         if (this.ifrlayer)
  471.         {
  472.             this.ifrlayer.move(this.balloonDIV);
  473.             this.ifrlayer.resize(this.balloonDIV);
  474.         }
  475.        // ieFix();   comment this line to fix case 12802: webtip is malformed on CBS (on DR) in IE7
  476.         // Show balloon
  477.         this.balloonDIV.style.visibility='visible';
  478.         ANSW.alert(this.balloonDIV.style.width);
  479.         if(ANSW.b5.isFirefox  && typeof deconcept!="undefined")
  480.         {
  481.             SuppressFlash();
  482.         }
  483.         this.tmrIFrameGone=setInterval(this.IFrameGone,400);
  484.     }
  485.     function IFrameGone()
  486.     {
  487.  
  488.         var mydoc= ANSW.isFirefoxExtension ? window.content.document : document;
  489.         var ac = ANSW.doc ? ANSW.doc.getElementById("answertipClose") : mydoc.getElementById("answertipClose");
  490.         if (ac)
  491.         {
  492.             var params=ac.innerHTML;
  493.             
  494.             if (params=="close")
  495.             {
  496.                 ac.innerHTML = "";
  497.                 ANSW.b5.Hide();
  498.             }
  499.             else if (params=="options")
  500.             {
  501.                 ac.innerHTML = "";
  502.                 var local ="";
  503.                 if (ANSW.b5.answersURL.indexOf(":8080")!= -1)
  504.                     local = "/answers"
  505.                 if(ANSW.isFirefoxExtension)
  506.                     window.openDialog("chrome://answers/content/options.xul", "1-Click Answers Options", "centerscreen,chrome,modal");
  507.                 else
  508.                     window.open(ANSW.b5.answersURL + local +"/main/transoptform?gwp=11");
  509.             }
  510.             else if (params.indexOf("checklang")==0)
  511.             {
  512.                 ac.innerHTML = "";
  513.                 if (params.indexOf("true")>-1)
  514.                     ANSW.b5.checklang(true);
  515.                 else
  516.                     ANSW.b5.checklang(false);
  517.             }
  518.             else if (params=="personalize")
  519.             {
  520.                 ac.innerHTML = "";
  521.                 ANSW.b5.Personalize();
  522.             }
  523.             else if (params.indexOf('?')==0)
  524.             {
  525.                 ac.innerHTML = "";
  526.                 params=params.replace(/&/g,"&");
  527.                 if (params.indexOf("&ok=1")>-1)
  528.                 {
  529.                     params+=ANSW.b5.getPrefs();
  530.                 }
  531.                 ANSW.b5.dymtip(params);
  532.             }
  533.         }
  534.     }
  535.     this.IFrameGone = IFrameGone;
  536.  
  537.      function isVisible()
  538.     {
  539.         if (this.balloonDIV)
  540.         {
  541.          if(this.balloonDIV.style.visibility=='hidden')
  542.             return false;
  543.          else
  544.             return true;
  545.         }
  546.         else
  547.             return false;
  548.     }
  549.     /*    Function: Hide
  550.             Hide a visible balloon.
  551.             Call this function to immediately initiate the hiding of the instantiated balloon
  552.             with the predefined transition in <transHideFilter> depending on the setting of <transHide>.
  553.     */
  554.  
  555.     function Hide()
  556.     {
  557.         clearInterval(this.tmrIFrameGone);
  558.         moveme_onmouseup(); // to remove the mousemove listener
  559.         if(!this.balloonDIV || this.balloonDIV.style.visibility=='hidden')
  560.         {
  561.             return;
  562.         }
  563.         this.balloonDIV.style.visibility='hidden';
  564.  
  565.         // kludge for bug in FF-Mac - scrollbar stays when window hidden
  566.         var mydoc= ANSW.isFirefoxExtension ? window.content.document : document;
  567.         var answertip = ANSW.doc ? ANSW.doc.getElementById("Answertip") : mydoc.getElementById("Answertip");
  568.         if (answertip)
  569.             answertip.style.overflow="hidden";
  570.         var answertipMore =    ANSW.doc ? ANSW.doc.getElementById("AnswertipMore") : mydoc.getElementById("AnswertipMore");
  571.         if (answertipMore==null || typeof (answertipMore) == "undefined")
  572.             answertipMore =    ANSW.doc ? ANSW.doc.getElementById("AnswertipCBSMore") : mydoc.getElementById("AnswertipCBSMore");
  573.         if (answertipMore)
  574.         {
  575.             answertipMore.style.visibility="hidden";
  576.         }
  577.         var AnswersAIC = ANSW.doc ? ANSW.doc.getElementById("AnswersAIC") : mydoc.getElementById("AnswersAIC");
  578.         if (AnswersAIC)
  579.             AnswersAIC.style.visibility="hidden";
  580.         if (ANSW.b5.ifrlayer)
  581.             ANSW.b5.ifrlayer.hide(this.balloonDIV);
  582.         if(ANSW.b5.isFirefox  && typeof deconcept!="undefined")
  583.               RestoreFlash();
  584.     }
  585.     function ObjectOverlap(obj1, obj2)
  586.     {
  587.         var obj1TopX = getLeft(obj1);
  588.         var obj1TopY = getTop(obj1);
  589.         var obj1BottomX = getLeft(obj1)+obj1.offsetWidth;
  590.         var obj1BottomY = getTop(obj1)+obj1.offsetHeight;
  591.  
  592.         var obj2TopX = getLeft(obj2);
  593.         var obj2TopY = getTop(obj2);
  594.         var obj2BottomX = getLeft(obj2)+obj2.offsetWidth;
  595.         var obj2BottomY = getTop(obj2)+obj2.offsetHeight;
  596.  
  597.         var overlapOnX = (obj1TopX < obj2BottomX && obj2TopX < obj1BottomX);
  598.         var overlapOnY = (obj1TopY < obj2BottomY && obj2TopY < obj1BottomY);
  599.  
  600.         return (overlapOnX && overlapOnY);
  601.     }
  602.  
  603.     //Positioning functions
  604.     function getObjLeft(anObject)
  605.     {
  606.       return (anObject.offsetParent ? (getObjLeft(anObject.offsetParent) + anObject.offsetLeft) : anObject.offsetLeft);
  607.     }
  608.  
  609.     function getObjTop(anObject)
  610.     {
  611.       return(anObject.offsetParent ? (getObjTop(anObject.offsetParent) + anObject.offsetTop) : anObject.offsetTop);
  612.     }
  613.  
  614.     function getLeft(anObject)
  615.     {
  616.         return(getObjLeft(anObject));
  617.     }
  618.  
  619.     function getTop(anObject)
  620.     {
  621.         return(getObjTop(anObject));
  622.     }
  623.  
  624.     function InsideObject(obj,x,y)
  625.     {
  626.         var objTopY =getTop(obj);
  627.         var objTopX = getLeft(obj);
  628.         var objBottomX = objTopX + obj.offsetWidth;
  629.         var objBottomY = objTopY + obj.offsetHeight;
  630.         var xInside = (x < objBottomX+4 && x > objTopX-1);
  631.         var yInside = (y < (objBottomY+10) && y > (objTopY-10));
  632.         return (xInside && yInside);
  633.     }
  634.  
  635.     function ScrollOffsets(anchor)
  636.     {
  637.         var aryScrolls = new Array(0,0);
  638.  
  639.         try
  640.         {
  641.             var parentElem=anchor.parentElement;
  642.  
  643.             while(parentElem!=null)
  644.             {
  645.                 if(parentElem.scrollTop!=null)
  646.                 {
  647.                     aryScrolls[0]+=parseInt(parentElem.scrollTop, 10);
  648.                     aryScrolls[1]+=parseInt(parentElem.scrollLeft, 10);
  649.                 }
  650.  
  651.                 parentElem=parentElem.parentElement;
  652.             }
  653.         }
  654.         catch(ex)
  655.         {
  656.             // continue
  657.         }
  658.         return aryScrolls;
  659.     }
  660.  
  661.  
  662.     function addHook(path,dir,cobrand)
  663.     {
  664.         var imageName;
  665.         var marginleft;
  666.         var top;
  667.         var height;
  668.         var width;
  669.         switch(dir)
  670.         {
  671.             case "SE":
  672.                 imageName="hook-bottomL";
  673.                 marginleft="25px";
  674.                 height="29px";
  675.                 width="70px";
  676.                 if (ANSW.b5.isIE6)
  677.                     top="-18px";
  678.                 else
  679.                     top="-15px";
  680.             break;
  681.             case "SW":
  682.                 imageName="hook-bottomR";
  683.                 marginleft="400px";
  684.                 height="29px";
  685.                 width="70px";
  686.                 if (ANSW.b5.isIE6)
  687.                     top="-19px";
  688.                 else
  689.                     top="-16px";
  690.             break;
  691.             case "NE":
  692.                 imageName="hook-topL";
  693.                 marginleft="25px";
  694.                 height="24px";
  695.                 width="67px";
  696.                 top="10px";
  697.             break;
  698.             case "NW":
  699.                 imageName="hook-topR";
  700.                 marginleft="400px";
  701.                 height="24px";
  702.                 width="67px";
  703.                 top="10px";
  704.             break;
  705.             default:
  706.             alert("bad direction");
  707.         }
  708.         var ret= '<DIV id="AnswerTipHook" style="background-image: url('+path+'/main/images/'+imageName +'.gif);width:'+width+';height:'+height+';margin-left:' +marginleft +';position:relative;top:'+top+';"></DIV>';
  709.         return ret;
  710.  
  711.     }
  712.     function addCBSBalloon(path,body,sponsor)
  713.     {
  714.     var balloon = '<div class="popupFrameA" id="popup_FrameA">'+
  715.     '<div class="popupHeader" id="popup_header">'+
  716.         '<div class="popupHeaderInner" id="AnswersHandle0" style="cursor:move;" handlefor="AnswersBalloon">'+
  717.             '<div class="popupHeader1" style="margin-right:-10px;margin-left:-6px;width:250px;';
  718.     balloon +=ANSW.Trigger.isSafari3?'width:247px;">':'">' ;
  719.     balloon +=    '<div style="float:left;margin-top:5px;color:white;" >Powered by</div>'+
  720.                   '<div><a style="float:left;" href="'+path+'"><img id="AnswersLogoCBSImage" style="position:relative;" border="0" align="top" alt="Visit Answers.com" src="'+path+'/main/images/answers_cbs_logo.gif"/></a></div>'+
  721.                   '<a style="float:left;cursor:hand;cursor:pointer;" onclick="var ac = document.getElementById(\'answertipClose\'); if (ac) ac.innerHTML=\'close\'; else window.status=\'close\'; return true;" ><img id="AnswersCBSCloseImage" border="0" align="top" alt="Close" src="'+path+'/main/images/close.gif"/></a>'  +
  722.  
  723.             '</div>'+
  724.             '<span class="AnswersHeader2" >Instant Information </span>'+
  725.         '</div>'+
  726.         '<div id="Answers_frame" class="AnswersContentFrame1">' +
  727.                 body+
  728.         '</div>'+
  729.  
  730.         '<div class="AnswersFooter" id="popup_footer">'+
  731.             sponsor+
  732.         '</div>'+
  733.     '</div>'+
  734. '</div>';
  735.         return balloon;
  736.     }
  737.     function addAdsBalloon(path,body,sponsor,ads)
  738.     {
  739.     var tracking = '' ;
  740.         if (ads>0)
  741.             tracking=ANSW.isFirefoxExtension?'?initiator=FFANS':'?initiator=WANS';
  742.         else
  743.             tracking='?initiator=WALLST';
  744.     var balloon = '<div class="AnswersHeaderW" id="AnswersHeader_W">'+
  745.         '<div class="AnswersHeaderInner" id="AnswersHandle0" style="cursor:move;" handlefor="AnswersBalloon">'+
  746.             '<div class="AnswersHeader1">'+
  747.                 '<a style="float:right;" onclick="var ac = document.getElementById(\'answertipClose\');if (ac) ac.innerHTML=\'close\'; else window.status=\'close\'; return true;" ><img id="AnswersCloseImage" style="margin-right:10px;position:relative;cursor:hand;cursor:pointer;" border="0" align="top" alt="Close" src="'+path+'/main/images/close.gif"/></a>'  +
  748.                 '<a id="AnswertipMore" target="AnswersQueryWindow" onclick="var ac = document.getElementById(\'answertipClose\'); if (ac) ac.innerHTML=\'close\'; else window.status=\'close\';return true;" style="float:right;text-decoration:none;visibility:hidden;padding-right:10px;margin-top:9px;cursor:hand;" ><span class="AnswersHeader3"> Read more >>  </span></a>';
  749.     balloon+= ANSW.isFirefoxExtension?'<a id="AnswertipOptions" onclick="var ac = document.getElementById(\'answertipClose\'); if (ac) ac.innerHTML=\'options\'; else window.status=\'options\';return true;" style="float:right;text-decoration:none;padding-right:10px;margin-top:9px;cursor: hand;cursor:pointer;" ><span class="AnswersHeader3"> Options >>  </span></a>':'';
  750.     balloon+= (ads>0)?'</div>':'<a href="http://www.wallst.net"><img id="WALLSTLogoImage" border="0" align="top" alt="Visit WallSt.net" src="'+path+'/main/images/answers_wallst.gif"/></a></div>';
  751.     balloon+= '<div><a style="float:left;" href="'+path+tracking+'"><img id="AnswersLogoImage" style=";" border="0" align="top" alt="Visit Answers.com" src="'+path+'/main/images/answers-logo.gif"/></a></div>'+
  752.         '</div>'+
  753.         '<div id="Answers_frame" class="AnswersContentFrame">' +
  754.                 body+
  755.         '</div>'+
  756.         '<div class="AnswersFooter" id="Answers_footer">'+
  757.             sponsor+
  758.         '</div>'+
  759. '</div>';
  760.         return balloon;
  761.     }
  762. function addAnswersBalloon(path,body,sponsor)
  763. {
  764.     var tracking = ANSW.isFirefoxExtension?'?initiator=FFANS':'?initiator=WANS';
  765.     var balloon = '<div class="AnswersHeader" >'+
  766.         '<div class="AnswersHeaderInner" id="AnswersHandle0" style="cursor:move;" handlefor="AnswersBalloon">'+
  767.             '<div class="AnswersHeader1">'+
  768.                 '<a style="float:right;" onclick="var ac = document.getElementById(\'answertipClose\'); if (ac) ac.innerHTML=\'close\'; else window.status=\'close\'; return true;" ><img id="AnswersCloseImage" style="margin-right:10px;position:relative;cursor:hand;cursor:pointer;" border="0" align="top" alt="Close" src="'+path+'/main/images/close.gif"/></a>'  +
  769.                 '<a id="AnswertipMore" target="AnswersQueryWindow" onclick="var ac = document.getElementById(\'answertipClose\'); if (ac) ac.innerHTML=\'close\'; else window.status=\'close\';return true;" style="float:right;text-decoration:none;visibility:hidden;padding-right:10px;margin-top:9px;cursor:hand;cursor:pointer;" ><span class="AnswersHeader3"> Read more >>  </span></a>';
  770.     balloon+= ANSW.isFirefoxExtension?'<a id="AnswertipOptions" onclick="var ac = document.getElementById(\'answertipClose\'); if (ac) ac.innerHTML=\'options\'; else window.status=\'options\';return true;" style="float:right;text-decoration:none;padding-right:10px;margin-top:9px;cursor:hand;cursor:pointer;" ><span class="AnswersHeader3"> Options >>  </span></a>':'';
  771.     balloon+= '</div>'+
  772.               '<div><a style="float:left;cursor:hand;cursor:pointer;" href="'+path+tracking+'"><img id="AnswersLogoImage" style=";" border="0" align="top" alt="Visit Answers.com" src="'+path+'/main/images/answers-logo.gif"/></a></div>'+
  773.         '</div>'+
  774.         '<div id="Answers_frame" class="AnswersContentFrame">' +
  775.                 body+
  776.         '</div>'+
  777.         '<div class="AnswersFooter" id="Answers_footer">'+
  778.             sponsor+
  779.         '</div>'+
  780. '</div>';
  781.         return balloon;
  782. }
  783.  
  784. function addAnswersBalloon2(path,body,sponsor)
  785. {
  786.     var tracking = ANSW.isFirefoxExtension?'?initiator=FFANS':'?initiator=WANS';
  787.     var balloon = '<div class="AnswersHeaderB" >'+
  788.         '<div class="AnswersHeaderInner" id="AnswersHandle0" style="cursor:move;" handlefor="AnswersBalloon">'+
  789.             '<div class="AnswersHeader1">'+
  790.                 '<a style="float:right;" onclick="var ac = document.getElementById(\'answertipClose\'); if (ac) ac.innerHTML=\'close\'; else window.status=\'close\'; return true;" ><img id="AnswersCloseImage" style="margin-right:10px;position:relative;cursor:hand;cursor:pointer;" border="0" align="top" alt="Close" src="'+path+'/main/images/close.gif"/></a>'  +
  791.                 '<a id="AnswertipMore" target="AnswersQueryWindow" onclick="var ac = document.getElementById(\'answertipClose\'); if (ac) ac.innerHTML=\'close\'; else window.status=\'close\';return true;" style="float:right;text-decoration:none;visibility:hidden;padding-right:10px;margin-top:9px;cursor:hand;cursor:pointer;" ><span class="AnswersHeader3"> Read more >>  </span></a>';
  792.     balloon+= ANSW.isFirefoxExtension?'<a id="AnswertipOptions" onclick="var ac = document.getElementById(\'answertipClose\'); if (ac) ac.innerHTML=\'options\'; else window.status=\'options\';return true;" style="float:right;text-decoration:none;padding-right:10px;margin-top:9px;cursor:hand;cursor:pointer;" ><span class="AnswersHeader3"> Options >>  </span></a>':'';
  793.     balloon+= '</div>'+
  794.               '<div><a style="float:left;cursor:hand;cursor:pointer;" href="'+path+tracking+'"><img id="AnswersLogoImage" style=";" border="0" align="top" alt="Visit Answers.com" src="'+path+'/main/images/answers-logo.gif"/></a></div>'+
  795.         '</div>'+
  796.         '<div id="Answers_frame" class="AnswersContentFrame">' +
  797.                 body+
  798.         '</div>'+
  799.         '<div class="AnswersFooter" id="Answers_footer">'+
  800.             sponsor+
  801.         '</div>'+
  802. '</div>';
  803.         return balloon;
  804. }
  805.  
  806. function addAnswersBalloon3(path,body,sponsor)
  807. {
  808.     var tracking = ANSW.isFirefoxExtension?'?initiator=FFANS':'?initiator=WANS';
  809.     var balloon = '<div class="AnswersHeaderA" >'+
  810.         '<div class="AnswersHeaderInner" id="AnswersHandle0" style="cursor:move;" handlefor="AnswersBalloon">'+
  811.             '<div class="AnswersHeader1">'+
  812.                 '<a style="float:right;" onclick="var ac = document.getElementById(\'answertipClose\'); if (ac) ac.innerHTML=\'close\'; else window.status=\'close\'; return true;" ><img id="AnswersCloseImage" style="margin-right:10px;position:relative;cursor:hand;cursor:pointer;" border="0" align="top" alt="Close" src="'+path+'/main/images/close.gif"/></a>'  +
  813.                 '<a id="AnswertipMore" target="AnswersQueryWindow" onclick="var ac = document.getElementById(\'answertipClose\'); if (ac) ac.innerHTML=\'close\'; else window.status=\'close\';return true;" style="float:right;text-decoration:none;visibility:hidden;padding-right:10px;margin-top:9px;cursor:hand;cursor:pointer;" ><span class="AnswersHeader3"> Read more >>  </span></a>';
  814.     balloon+= ANSW.isFirefoxExtension?'<a id="AnswertipOptions" onclick="var ac = document.getElementById(\'answertipClose\'); if (ac) ac.innerHTML=\'options\'; else window.status=\'options\';return true;" style="float:right;text-decoration:none;padding-right:10px;margin-top:9px;cursor:hand;cursor:pointer;" ><span class="AnswersHeader3"> Options >>  </span></a>':'';
  815.     balloon+= '</div>'+
  816.               '<div><a style="float:left;cursor:hand;cursor:pointer;" href="'+path+tracking+'"><img id="AnswersLogoImage" style=";" border="0" align="top" alt="Visit Answers.com" src="'+path+'/main/images/answers-logo.gif"/></a></div>'+
  817.         '</div>'+
  818.         '<div id="Answers_frame" class="AnswersContentFrame">' +
  819.                 body+
  820.         '</div>'+
  821.         '<div class="AnswersFooter" id="Answers_footer">'+
  822.             sponsor+
  823.         '</div>'+
  824. '</div>';
  825.         return balloon;
  826. }
  827.     function addAnswersBalloon4(path,body)
  828. {
  829.     var tracking = ANSW.isFirefoxExtension?'?initiator=FFANS':'?initiator=WANS';
  830.     var balloon = '<div class="AnswersHeaderC" >'+
  831.         '<div class="AnswersHeaderInner" id="AnswersHandle0" style="cursor:move;" handlefor="AnswersBalloon">'+
  832.             '<div class="AnswersHeader4">'+
  833.                 '<a style="float:right;" onclick="var ac = document.getElementById(\'answertipClose\'); if (ac) ac.innerHTML=\'close\'; else window.status=\'close\'; return true;" ><img id="AnswersCloseImage" style="margin-right:10px;position:relative;cursor:hand;cursor:pointer;" border="0" align="top" alt="Close" src="'+path+'/main/images/close.gif"/></a>'  +
  834.                 '<a id="AnswertipMore" target="AnswersQueryWindow" onclick="var ac = document.getElementById(\'answertipClose\'); if (ac) ac.innerHTML=\'close\'; else window.status=\'close\';return true;" style="float:right;text-decoration:none;visibility:hidden;padding-right:10px;margin-top:9px;cursor:hand;cursor:pointer;" ><span class="AnswersHeader3"> <u>More</u>  </span></a>';
  835.     balloon+= ANSW.isFirefoxExtension?'<a id="AnswertipOptions" onclick="var ac = document.getElementById(\'answertipClose\'); if (ac) ac.innerHTML=\'options\'; else window.status=\'options\';return true;" style="float:right;text-decoration:none;padding-right:10px;margin-top:9px;cursor:hand;cursor:pointer;" ><span class="AnswersHeader3"> Options >>  </span></a>':'';
  836.     balloon+= '</div>'+
  837.               '<div><a style="float:left;cursor:hand;cursor:pointer;" href="'+path+tracking+'"><img id="AnswersLogoImage1" style=";" border="0" align="top" alt="Visit Answers.com" src="'+path+'/main/images/answers-logo.png"/></a></div>'+
  838.         '</div>'+
  839.         '<div id="Answers_frame" class="AnswersContentFrame">' +
  840.                 body+
  841.         '</div>'+
  842.         '<div class="AnswersFooter" id="Answers_footer">'+
  843.             '<TR cellpadding=0 cellspacing=0><TD>'+
  844.         '<div style="width: 540px; height: 22px; float: left; margin-top: 6px; color: yellow; font-size: 9pt; text-align: center;">'+
  845.         '<u><b><a style="color:yellow;" href="/main/answertips.jsp?lid=AnswerTip_enable&lpos=ATip_bottom">AnswerTips</a></u> - you can double-click on any word on your page.</b>'+
  846.         '</DIV>    </TD></TR>'+
  847.         '</div>'+
  848. '</div>';
  849.         return balloon;
  850. }
  851.     function ieFix(){
  852.     // also some css specific to IE to work around IE bugs
  853.     if(document.all){
  854.         var popupHeaderInner = document.getElementById('popup_header');
  855.         if (popupHeaderInner)
  856.         {
  857.                 popupHeaderInner.style['margin'] = '0px 8px 18px 8px';
  858.         popupHeaderInner.style['width'] = '465px';
  859.         popupHeaderInner.style['padding-top'] =  '8px';
  860.             }
  861.         var popupFooter = document.getElementById('popup_footer');
  862.          if (popupFooter)
  863.             popupFooter.style['margin-right'] = '4px';
  864.  
  865.                 // To add a shadow, use this.  Comment out to disable
  866.         var popupFrameA = document.getElementById('popup_FrameA');
  867.         if (popupFrameA)
  868.         {
  869.             popupFrameA.style['background-image']  = 'url(http://wwwimage.cbsnews.com/common/images/v2/popup_shadow.jpg)';
  870.             popupFrameA.style['background-repeat'] = 'no-repeat';
  871.         }
  872.     }
  873. }
  874.  
  875.     function addBalloon(path,dir,cobrand,body,sponsor,ads,nafid)
  876.     {
  877.         if (cobrand=="cbs")
  878.             return addCBSBalloon(path,body,sponsor);
  879.         else
  880.         {
  881.             var ballon;
  882.             switch(cobrand)
  883.             {
  884.                 case "wallst":
  885.                     ballon = addAdsBalloon(path,body,sponsor,0);
  886.                     break;
  887.                 default:
  888.                     ballon = addAnswersBalloon(path,body,sponsor);
  889.                     break;
  890.             }
  891.             if (ads>0)
  892.                     ballon = addAdsBalloon(path,body,sponsor,ads);
  893.             if (nafid==100)
  894.                     ballon = addAdsBalloon(path,body,sponsor,2);
  895.             if (ANSW.aic==1)
  896.                     ballon = addAnswersBalloon3(path,body,sponsor);
  897.             if (ANSW.aic==2)
  898.                     ballon = addAnswersBalloon4(path,body);
  899.             return  (dir.indexOf("N")>-1?addHook(path,dir,cobrand):'')+
  900.                 ballon+
  901.                 (dir.indexOf("S")>-1?addHook(path,dir,cobrand):'');
  902.         }
  903.     }
  904.  
  905.     // Rendering functions
  906.     function balloonInfrastructure(body, path,direction,query,nafid,cobrand,ads)
  907.     {
  908.         var ret;
  909.         var local ="";
  910.         var url="";
  911.         var sponsor="";
  912.         if (this.answersURL.indexOf(":8080")!= -1)
  913.             local = "/answers"
  914.         if (typeof(cobrand)=="undefined" || !cobrand)
  915.             cobrand='';
  916.         var adHeight="22px"
  917.         if (typeof nafid != "undefined" && nafid!=null)
  918.         {
  919.             switch(nafid)
  920.             {
  921.                 case 5:  //JPost
  922.                 adHeight="62px";
  923.                 break;
  924.                 case 100: //MTVU
  925.                 adHeight="62px";
  926.                 break;
  927.                 default:
  928.                 adHeight="22px";
  929.                 break;
  930.             }
  931.         }
  932.         if (typeof cobrand != "undefined")
  933.         {
  934.             switch(cobrand)
  935.             {
  936.                 case "cbs":  //cbs with ads
  937.                 adHeight="62px";
  938.                 break;
  939.                 case "wallst":
  940.                 adHeight="60px";
  941.                 if (ANSW.b5.isIE)
  942.                     adHeight +=";margin-top:-1px;"
  943.                 break;
  944.                 default:
  945.                 break;
  946.             }
  947.         }
  948.         if    (ads==0)
  949.             url = this.answersURL + local + '/main/tip2.jsp?s=' + encodeURIComponent(query) +'&wt=1&nafid=' + nafid +'&cobrand=' + cobrand ;
  950.         else
  951.             adHeight="61px";
  952.         sponsor='<TR cellpadding=0 cellspacing=0><TD>'+
  953.         '<DIV style="width:471px;height:'+adHeight+';float:left;">'+
  954.         '<iframe id="AnswersAds" type="content" scrolling="no" FRAMEBORDER="0" allowTransparency="true" style="padding:0px;border:0px;width:100%;height:'+adHeight+'" src="'+url +'"></iframe>'+
  955.         '</DIV>    </TD></TR>';
  956.         return addBalloon(path,direction,cobrand,body,sponsor,ads,nafid);
  957.     }
  958.  
  959.     this.balloonInfrastructure = balloonInfrastructure;
  960.  
  961.     function balloonBody(title, showCloseBox,cobrand)
  962.     {
  963.         var body="";
  964.         if (typeof(cobrand)=="undefined" || !cobrand)
  965.             cobrand='';
  966.         var ret= '<table id="Balloontable2'+cobrand+'" class="donotmoveme" style="width:480px;float:left;"><TR><TD> <DIV id="Answertip" style="overflow-x:hidden;overflow:auto;height:';
  967.         ret +=(cobrand=="cbs")?'228px;background-color:white;':(ANSW.aic==1)?'305px;':(ANSW.aic==2)?'305px;':'235px;';
  968.         ret +=ANSW.aic==1?'width:495px;">':ANSW.aic==2?'width:563px;">':'width:473px;">';
  969.         ret += body + '</DIV> <DIV id="answertipClose" style="display:none;" ></DIV></TD></TR></table>';
  970.         return ret;
  971.     }
  972.     function SendQuery(obj,topic,nohook)
  973.     {
  974.         var top = getTop(obj);
  975.         var left = getLeft(obj);
  976.         var query = obj.innerHTML.replace(/<br>/gi," ").replace(/<[^>]+>/g,"");
  977.         this.FireQuery(query,top,left,-1,null,topic,nohook);
  978.  
  979.         return false;
  980.     }
  981.     this.SendQuery = SendQuery;
  982.     function dymtip(params)
  983.     {
  984.         var mydoc= ANSW.isFirefoxExtension ? window.content.document : document;
  985.         var tmp=mydoc.getElementById('perdymtip');
  986.         params +=(params && typeof params!="undefined" && params.length>0)?"&":"?";
  987.         if (tmp)
  988.         {
  989.             if (ANSW.isFirefoxExtension)
  990.                 params +="o=0&gwp=22";
  991.             else
  992.                 params +="o=2&gwp=21";
  993.             params += (document.charset ? ("&encoding=" + document.charset) : "");
  994.             params += "&dym="+encodeURIComponent(tmp.innerHTML.replace(/\'/g,'%27').replace(/\n/g,'%20')) ;
  995.         }
  996.         loadScript("answertip.jsp","answertipScript",null,params);
  997.     }
  998.     this.dymtip = dymtip;
  999.     function Personalize()
  1000.     {
  1001.         var params ="" ;
  1002.         if (ANSW.isFirefoxExtension)
  1003.             params +="?o=0&gwp=22";
  1004.         else
  1005.             params +="?o=2&gwp=21";
  1006.         params +="&per=1";
  1007.         var mydoc= ANSW.isFirefoxExtension ? window.content.document : document;
  1008.         var answertipJS = mydoc.getElementById("answertipScript");
  1009.          var encoding = (document.charset ? ("&encoding=" + document.charset) : "");
  1010.         params += encoding;
  1011.         if (answertipJS && answertipJS.src)
  1012.         {
  1013.             params +="&prevurl=";
  1014.             params +=encodeURIComponent(answertipJS.src) ;
  1015.         }
  1016.         loadScript("answertip.jsp","answertipScript",null,params);
  1017.     }
  1018.     this.Personalize = Personalize;
  1019.     function FireQuery(search,top,left,fw,elem,topic,nohook,fc)
  1020.     {
  1021.         var mydoc = ANSW.isFirefoxExtension?window.content.document:document;
  1022.         if (ANSW.b5.isIE && document.readyState!="complete")
  1023.             return;
  1024.         var query = encodeURIComponent(search);
  1025.         if (typeof topic != "undefined" && topic!=null && topic!='')
  1026.             topic =  encodeURIComponent(topic);
  1027.         var focusword= getFocusWord(query,fw);
  1028.         if (ANSW.isFirefoxExtension)
  1029.         {
  1030.             ANSW.Balloon.prototype.answersURL= "http://" + ANSW.server;
  1031.             ANSW.Balloon.prototype.JSBalloonPath=ANSW.Balloon.prototype.answersURL;
  1032.         }
  1033.         this.Show({title:'', top:top,left:left,query:focusword,nafid:ANSW.nafid,cobrand:ANSW.cobrand,nohook:nohook,parent:elem,ads:ANSW.ads});
  1034.         if (isBoolPrefEnabled("javascript.enabled"))
  1035.             ensureScriptIsLoaded(query,fw,elem,ANSW.nafid,topic,ANSW.cobrand,fc);
  1036.         else
  1037.         {
  1038.             var answertipCss = mydoc.getElementById("answertipCSS");
  1039.             if (typeof answertipCss == "undefined" || answertipCss==null)
  1040.             {
  1041.                 loadCSS(mydoc);
  1042.             }
  1043.             var answertip = mydoc.getElementById("Answertip");
  1044.             answertip.innerHTML= 'You need to enable Javascript to have this feature working. Hit ESC to close the AnswerTip.';
  1045.         }
  1046.     }
  1047.     this.FireQuery = FireQuery;
  1048.     function getFocusWord(search,fw)
  1049.     {
  1050.         if (fw<0)
  1051.             return search;
  1052.         else
  1053.         {
  1054.             var trimmed = ANSW.trim(search);
  1055.             var arrFW = trimmed.split(" ");
  1056.             if ((arrFW.length-1)>=fw)
  1057.                 return arrFW[fw];
  1058.             else
  1059.                 return search;
  1060.         }
  1061.     }
  1062.     function isBoolPrefEnabled(pref)
  1063.     {
  1064.         if (ANSW.isFirefoxExtension)
  1065.         {
  1066.             var preferencesService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  1067.             return preferencesService.getBoolPref(pref);
  1068.         }
  1069.         else
  1070.             return true;
  1071.     }
  1072.     function ensureScriptIsLoaded(query,fw,elem,nafid,topic,cobrand,fc)
  1073.     {
  1074.         var mydoc= ANSW.isFirefoxExtension ? window.content.document : document;
  1075.         if (elem)
  1076.         {
  1077.             mydoc = elem.parentNode;
  1078.             mydoc= mydoc.parentNode;
  1079.             ANSW.doc = mydoc;
  1080.         }
  1081.         if (ANSW.doc)
  1082.             mydoc=ANSW.doc;
  1083.         var answertipJS = mydoc.getElementById("answertipScript");
  1084.         var answertipCss = mydoc.getElementById("answertipCSS");
  1085.         var answertipSound = mydoc.getElementById("answertipSound");
  1086.         var head = mydoc.getElementsByTagName("head")[0];
  1087.         var script;
  1088.         var scriptSound;
  1089.         var local="";
  1090.         var src="";
  1091.         script = mydoc.createElement('script');
  1092.         script.id = 'answertipScript';
  1093.         script.type = 'text/javascript';
  1094.  
  1095.         if (ANSW.isFirefoxExtension)
  1096.             ANSW.b5.answersURL= "http://" + ANSW.server;
  1097.         if (ANSW.b5.answersURL.indexOf(":8080")!= -1)
  1098.             local = "/answers"
  1099.         src = ANSW.b5.answersURL + local + "/main/answertip.jsp?";
  1100.         if (typeof topic != "undefined" && topic!=null && topic!='')
  1101.             src +="tname=" +topic;  // s was already passed to the ads
  1102.         else
  1103.             src +="s=" +query;
  1104.         src += "&fw="+fw;
  1105.         if (fc>=0)
  1106.             src += "&fc="+fc;
  1107.         if (ANSW.isFirefoxExtension)
  1108.             src +="&o=0&gwp=22";
  1109.         else
  1110.             src +="&o=2&gwp=21";
  1111.         var encoding = (document.charset ? ("&encoding=" + document.charset) : "");
  1112.         src += encoding;
  1113.         if (typeof nafid != "undefined" && nafid!=null && nafid!='')
  1114.                 src +="&nafid=" +nafid;
  1115.         if (typeof cobrand != "undefined" && cobrand!=null && cobrand!='')
  1116.             src +="&cobrand=" +cobrand;
  1117.         if(!ANSW.isFirefoxExtension)
  1118.             src += "&ats="+encodeURIComponent(location.href);
  1119.         if (typeof ANSW.version!="undefined" && ANSW.version!="")
  1120.             src += "&ver="+ANSW.version;
  1121.         if (typeof ANSW.ads!="undefined" && ANSW.ads!=0)
  1122.             src += "&as="+ANSW.ads;
  1123.         if (typeof ANSW.adw!="undefined" && ANSW.adw!=0)   // ad width
  1124.             src += "&adw="+ANSW.adw;
  1125.         if (typeof ANSW.adh!="undefined" && ANSW.adh!=0)   //ad height
  1126.             src += "&adh="+ANSW.adh;
  1127.         if (typeof ANSW.aic!="undefined" && ANSW.aic!=0)    // ad in content for aic=1, no ad in content aic=2
  1128.             src += "&aic="+ANSW.aic;
  1129.         if (typeof ANSW.afid!="undefined" && ANSW.afid!="")    // pass an afid
  1130.             src += "&afid="+ANSW.afid;
  1131.         var ord=Math.random()*10000000000000000;
  1132.         src += "&ord="+ord;    // fix case 12685
  1133.         script.src = src;
  1134.         if (answertipJS)
  1135.         {
  1136.             if (ANSW.b5.isIE)
  1137.                 answertipJS.src = src;
  1138.             else
  1139.                 head.replaceChild(script,answertipJS);
  1140.         }
  1141.         else
  1142.             head.appendChild(script);
  1143.         var sPron=  mydoc.getElementById("sPron");
  1144.         if (!sPron)
  1145.             sPron = mydoc.getElementById("sSpan");
  1146.         if (!sPron)
  1147.             sPron = mydoc.getElementsByTagName("bgsound")[0];
  1148.         if (!(answertipSound) && !(sPron)){
  1149.             scriptSound = mydoc.createElement('script');
  1150.             scriptSound.id = 'answertipSound';
  1151.             scriptSound.type = 'text/javascript';
  1152.             scriptSound.src =ANSW.b5.JSBalloonPath + "/main/lookup/sound.js";
  1153.             head.appendChild(scriptSound);
  1154.         }
  1155.         if (typeof answertipCss == "undefined" || answertipCss==null)
  1156.         {
  1157.             loadCSS(mydoc);
  1158.         }
  1159.         if (typeof cobrand != "undefined" && cobrand!=null && cobrand!='')
  1160.         {
  1161.             var answertipCssCobrand = mydoc.getElementById("answertipCSS"+cobrand);
  1162.             if (typeof (answertipCssCobrand ) == "undefined" || answertipCssCobrand==null)
  1163.             {
  1164.                 if (cobrand=='cbs')
  1165.                     loadSingleCSS('http://www.cbsnews.com/common/css/v2_main.css','answertipCSS'+cobrand,mydoc);
  1166.                 else
  1167.                     loadSingleCSS('web_tip_'+cobrand +'.css','answertipCSS'+cobrand,mydoc);
  1168.             }
  1169.         }
  1170.     }
  1171.     function loadCSS(mydoc)
  1172.     {
  1173.         loadSingleCSS('web_tip.css','answertipCSS',mydoc);
  1174.  
  1175.     }
  1176.     this.loadCSS = loadCSS;
  1177.     function loadSingleCSS(filename,id,mydoc)
  1178.     {
  1179.         var head = mydoc.getElementsByTagName("head")[0];
  1180.         var css;
  1181.         var local = ""
  1182.         css = mydoc.createElement('link');
  1183.         css.type = 'text/css';
  1184.         css.rel = 'stylesheet';
  1185.         if (filename.indexOf("http://")==0)
  1186.             css.href = filename;
  1187.         else
  1188.             css.href = ANSW.b5.JSBalloonPath + "/main/lookup/" +filename;
  1189.         css.id = id;
  1190.         head.appendChild(css);
  1191.     }
  1192.     this.loadSingleCSS = loadSingleCSS;
  1193.     function loadSingleScript(filename,id,mydoc)
  1194.     {
  1195.         var head = mydoc.getElementsByTagName("head")[0];
  1196.         var answersautotip = mydoc.getElementById("answersautotip");
  1197.         if (typeof answersautotip == "undefined" || answersautotip==null)
  1198.         {
  1199.             var script;
  1200.             script = mydoc.createElement('script');
  1201.             script.type = 'text/javascript';
  1202.             if (filename.indexOf("http://")==0)
  1203.                 script.src = filename;
  1204.             else
  1205.                 script.src = ANSW.b5.JSBalloonPath + "/main/lookup/" +filename;
  1206.             script.id = id;
  1207.             head.appendChild(script);
  1208.         }
  1209.     }
  1210.     this.loadSingleScript = loadSingleScript;
  1211.     function loadScript(filename,id,pathParm,params)
  1212.     {
  1213.         if (pathParm==null){
  1214.             pathParm = ANSW.b5.JSBalloonPath;
  1215.             if (pathParm.indexOf(":8080")!= -1)
  1216.                 pathParm += "/answers"
  1217.         }
  1218.         var mydoc= ANSW.isFirefoxExtension ? window.content.document : document;
  1219.         var scriptNode = mydoc.getElementById(id);
  1220.         var head = mydoc.getElementsByTagName("head")[0];
  1221.         var script;
  1222.         script = mydoc.createElement('script');
  1223.         script.type = 'text/javascript';
  1224.         script.src = pathParm + "/main/" +filename;
  1225.  
  1226.         var encoding = (document.charset ? ("encoding=" + document.charset) : "");
  1227.         if (encoding!="")
  1228.         {
  1229.             if (params && typeof params!="undefined")
  1230.                 params +="&"+encoding;
  1231.             else
  1232.                 params="?"+encoding
  1233.         }
  1234.         script.src    += params;
  1235.         script.id = id;
  1236.         if (scriptNode)
  1237.         {
  1238.             if (ANSW.b5.isIE)
  1239.                 scriptNode.src = script.src;
  1240.             else
  1241.                 head.replaceChild(script,scriptNode);
  1242.         }
  1243.         else
  1244.             head.appendChild(script);
  1245.         return false;// the jsp will turn it true if needed
  1246.     }
  1247.     this.loadScript = loadScript;
  1248.     function checkall(field,checkflag)
  1249.     {
  1250.         if (checkflag) {
  1251.         for (i = 0; i < field.length; i++) {
  1252.         field[i].checked = true;}
  1253.         }
  1254.         else {
  1255.         for (i = 0; i < field.length; i++) {
  1256.         field[i].checked = false; }
  1257.         }
  1258.     }
  1259.     this.checkall=checkall;
  1260.     function checklang(checkflag)
  1261.     {
  1262.         var mydoc= ANSW.isFirefoxExtension ? window.content.document : document;
  1263.         var field=mydoc.getElementsByName("tlang");
  1264.         if (field!=null && typeof field!="undefined")
  1265.         {
  1266.             if (checkflag) {
  1267.             for (i = 0; i < field.length; i++) {
  1268.             field[i].checked = true;}
  1269.             }
  1270.             else {
  1271.             for (i = 0; i < field.length; i++) {
  1272.             field[i].checked = false; }
  1273.             }
  1274.         }
  1275.     }
  1276.     this.checklang=checklang;
  1277.     function getPrefs(form)
  1278.     {
  1279.         var mydoc= ANSW.isFirefoxExtension ? window.content.document : document;
  1280.         var prefs="&per=2";
  1281.         var tabOrder=mydoc.getElementsByName("tabOrder");
  1282.         var tlang=mydoc.getElementsByName("tlang");
  1283.         if (form!=null && typeof form!="undefined")
  1284.         {
  1285.             tabOrder=form.tabOrder;
  1286.             tlang=form.tlang;
  1287.         }
  1288.          for (i=0, n=tabOrder.length; i<n; i++)
  1289.          {
  1290.             if (tabOrder[i].checked)
  1291.             {
  1292.                 prefs+="&tabOrder="+ tabOrder[i].value;
  1293.                 break;
  1294.             }
  1295.          }
  1296.         for (i=0, n=tlang.length; i<n; i++)
  1297.         {
  1298.             if (tlang[i].checked) {
  1299.                 prefs+="&tlang="+ tlang[i].value;
  1300.             }
  1301.          }
  1302.         return prefs;
  1303.     }
  1304.     this.getPrefs=getPrefs;
  1305.     function onkeyup(ev)
  1306.     {
  1307.         if(!ev && window.event)
  1308.         {
  1309.             ev=window.event;
  1310.         }
  1311.         var keycode = ev.keyCode;
  1312.         if (keycode == 27) // esc
  1313.         {
  1314.             ANSW.b5.Hide();
  1315.         }
  1316.         if (ANSW.isFirefoxExtension)
  1317.         {
  1318.             if ((keycode == 18 || keycode ==17)&& ANSW.leftbuttondown==true)//alt or ctrl
  1319.             {
  1320.                 ANSW.leftbuttondown=false;
  1321.                 ev.stopPropagation();
  1322.                 ev.preventDefault();
  1323.                 return false;
  1324.             }
  1325.         }
  1326.         if (ANSW.b5.isIE || ANSW.b5.isOpera)
  1327.         {
  1328.             if (ANSW.b5.oldkeyup)
  1329.                 return ANSW.b5.oldkeyup() ;
  1330.         }
  1331.     }
  1332.     this.onkeyup = onkeyup;
  1333.  
  1334.     function mdown(ev)
  1335.     {
  1336.         if(ANSW.b5.isVisible())
  1337.         {
  1338.             if(!ev && window.event)
  1339.             {
  1340.                 ev=window.event;
  1341.             }
  1342.             var el = ANSW.b5.isIE ? ev.srcElement:ev.target;
  1343.             ANSW.b5.checkDown(ev,el);
  1344.         }
  1345.         if (ANSW.b5.isIE || ANSW.b5.isOpera)
  1346.         {
  1347.             if (ANSW.b5.oldmousedown)
  1348.                 return ANSW.b5.oldmousedown() ;
  1349.         }
  1350.     }
  1351.     this.mdown = mdown;
  1352.  
  1353.     function checkDown(ev,elem)
  1354.     {
  1355.         var el = this.getReal(elem);
  1356.         if (ANSW.b5.isIE)
  1357.         {
  1358.             var sElem = "";
  1359.             sElem = document.body.componentFromPoint( ev.clientX,ev.clientY) ;
  1360.             if (sElem.indexOf("scrollbar")==0)
  1361.                 this.moveme_onmousedown(ev,el);
  1362.             else if (el.id==null )
  1363.             {
  1364.                 this.Hide();
  1365.             }
  1366.             else if (el.id =="AnswersBalloon" || el.id=="AnswersSponsor")
  1367.                 this.moveme_onmousedown(ev,el);
  1368.             else if (el.getAttribute("handlefor") == null || el.getAttribute("handlefor") == "")
  1369.             {
  1370.                 this.Hide();
  1371.             }
  1372.             else
  1373.                 this.moveme_onmousedown(ev,el);
  1374.         }
  1375.         else
  1376.         {
  1377.             var mydoc = ANSW.isFirefoxExtension?window.content.document:document;
  1378.             // firefox has always the scrollbar on the right side even if dir==rtl
  1379.             if (mydoc.documentElement.scrollWidth<ev.pageX || mydoc.documentElement.scrollHeight<ev.pageY)
  1380.             {
  1381.                 this.moveme_onmousedown(ev,el);
  1382.             }
  1383.             else if (typeof el=="undefined" || el==null || typeof el.id=="undefined" || el.id==null || el.id=='')
  1384.             {
  1385.                 this.Hide();
  1386.             }
  1387.             else if (el.id =="AnswersBalloon" || el.id=="AnswersSponsor")
  1388.                 this.moveme_onmousedown(ev,el);
  1389.             else if (el.getAttribute("handlefor") == null || el.getAttribute("handlefor") == "")
  1390.             {
  1391.                 this.Hide();
  1392.             }
  1393.             else
  1394.             {
  1395.                 this.moveme_onmousedown(ev,el);
  1396.             }
  1397.         }
  1398.     }
  1399.     this.checkDown = checkDown;
  1400.  
  1401.     var dragobject = null;
  1402.  
  1403.     var tx;
  1404.     var ty;
  1405.  
  1406.     var ie5 = document.all != null && document.getElementsByTagName != null;
  1407.     this.ie5 = ie5;
  1408.     function getReal(el) {
  1409.         temp = el;
  1410.         while ((temp != null) && (temp.tagName != "BODY") && (temp.tagName != "window"))
  1411.         {
  1412.              if ( temp.id==null || temp.id.indexOf("AnswersHandle")==0  ||  temp.id.indexOf("AnswersBalloon")==0  ||  temp.id.indexOf("AnswersSponsor")==0)
  1413.             {
  1414.                 el = temp;
  1415.                 break;
  1416.             }
  1417.             if (ANSW.b5.isIE)
  1418.                 temp = temp.parentElement;
  1419.             else
  1420.                 temp = temp.parentNode;
  1421.         }
  1422.         return el;
  1423.     }
  1424.     this.getReal = getReal;
  1425.     function moveme_onmousedown(ev,el)
  1426.     {
  1427.         var mydoc = ANSW.isFirefoxExtension?window.content.document:document;
  1428.         var tmp = null;
  1429.         if (typeof el  !="undefined" && el && typeof el.getAttribute !="undefined"){
  1430.             tmp = el.getAttribute("handlefor");
  1431.         }
  1432.         if (tmp == null || tmp=='')
  1433.         {
  1434.             dragobject = null;
  1435.             return true;
  1436.         }
  1437.         else
  1438.         {
  1439.            dragobject = ANSW.doc ? ANSW.doc.getElementById(tmp) : mydoc.getElementById(tmp);
  1440.             if(ANSW.b5.isIE) {
  1441.                 ANSW.b5.oldmousemove=document.onmousemove;
  1442.                 document.onmousemove=ANSW.b5.moveme_onmousemove;
  1443.             }
  1444.             else
  1445.             {
  1446.                 mydoc.addEventListener("mousemove",ANSW.b5.moveme_onmousemove,false);
  1447.             }
  1448.         }
  1449.         ty = ANSW.b5.isIE? ev.clientY - this.getTopPos(dragobject):ev.pageY - this.getTopPos(dragobject);
  1450.         tx = ANSW.b5.isIE? ev.clientX - this.getLeftPos(dragobject):ev.pageX - this.getLeftPos(dragobject);
  1451.         if (ANSW.b5.isIE)
  1452.         {
  1453.            ANSW.b5.ifrlayer.move(dragobject);
  1454.            ev.returnValue = false;
  1455.            ev.cancelBubble = true;
  1456.         }
  1457.         else
  1458.         {
  1459.             ANSW.b5.ifrlayer.move(dragobject);
  1460.             ev.stopPropagation();
  1461.             ev.preventDefault();
  1462.             return false;
  1463.         }
  1464.     }
  1465.     this.moveme_onmousedown = moveme_onmousedown;
  1466.  
  1467.     function moveme_onmouseup()
  1468.     {
  1469.         if(dragobject) {
  1470.             var mydoc = ANSW.isFirefoxExtension?window.content.document:document;
  1471.             dragobject = null;
  1472.              if(ANSW.b5.isIE) {
  1473.                 document.onmousemove=ANSW.b5.oldmousemove;
  1474.             }
  1475.             else
  1476.                  mydoc.removeEventListener("mousemove",ANSW.b5.moveme_onmousemove,false);
  1477.         }
  1478.         if (ANSW.b5.isIE || ANSW.b5.isOpera)
  1479.         {
  1480.             if (ANSW.b5.oldmouseup)
  1481.                 return ANSW.b5.oldmouseup() ;
  1482.         }
  1483.     }
  1484.     this.moveme_onmouseup = moveme_onmouseup;
  1485.  
  1486.     function moveme_onmousemove(ev)
  1487.     {
  1488.         if (typeof dragobject!="undefined" && dragobject!=null)
  1489.         {
  1490.             if(!ev && window.event)
  1491.             {
  1492.                 ev=window.event;
  1493.             }
  1494.             if (ANSW.b5.isIE)
  1495.             {
  1496.                 if (ev.clientX >= 0 && ev.clientY >= 0) {
  1497.                     dragobject.style.left = (ev.clientX - tx)  + "px";
  1498.                     dragobject.style.top = (ev.clientY - ty)  + "px";
  1499.                     ANSW.b5.ifrlayer.move(dragobject);
  1500.                 }
  1501.                 ev.returnValue = false;
  1502.                 ev.cancelBubble = true;
  1503.             }
  1504.             else
  1505.             {
  1506.                 if (ev.pageX >= 0 && ev.pageY >= 0)
  1507.                 {
  1508.                     dragobject.style.left =  (ev.pageX - tx) + "px";
  1509.                     dragobject.style.top = (ev.pageY - ty) + "px";
  1510.                     ANSW.b5.ifrlayer.move(dragobject);
  1511.                 }
  1512.                 ev.stopPropagation();
  1513.                 ev.preventDefault();
  1514.                 return false;
  1515.             }
  1516.         }
  1517.     }
  1518.     this.moveme_onmousemove = moveme_onmousemove;
  1519.  
  1520.     function getLeftPos(el) {
  1521.         if (this.ie5 && !this.isOpera) {
  1522.             if (el.currentStyle.left == "auto")
  1523.                 return 0;
  1524.             else
  1525.                 return parseInt(el.currentStyle.left);
  1526.         }
  1527.         else
  1528.         {
  1529.             return this.isIE ? el.style.pixelLeft:parseInt(el.style.left);
  1530.         }
  1531.     }
  1532.     this.getLeftPos = getLeftPos;
  1533.  
  1534.     function getTopPos(el) {
  1535.         if (this.ie5 && !this.isOpera) {
  1536.             if (el.currentStyle.top == "auto")
  1537.                 return 0;
  1538.             else
  1539.                 return parseInt(el.currentStyle.top);
  1540.         }
  1541.         else
  1542.         {
  1543.             return this.isIE? el.style.pixelTop:parseInt(el.style.top);
  1544.         }
  1545.     }
  1546.     this.getTopPos = getTopPos;
  1547.     function onRightClick(ev)
  1548.     {
  1549.  
  1550.          if(!ev && window.event)
  1551.         {
  1552.             ev=window.event;
  1553.         }
  1554.         var el = ANSW.b5.isFirefox ? (ANSW.isFirefoxExtension ?ev.originalTarget:ev.target):ev.srcElement;
  1555.         var elem = ANSW.b5.getReal(el);
  1556.         if (elem && elem.id == "AnswersBalloon")
  1557.         {
  1558.  
  1559.             if (ANSW.b5.isFirefox)
  1560.             {
  1561.                 ev.preventDefault();
  1562.                 ev.stopPropagation();
  1563.                 return false;
  1564.             }
  1565.             else
  1566.             {
  1567.                 ev.returnValue = false;
  1568.                 ev.cancelBubble = true;
  1569.                 return false;
  1570.             }
  1571.         }
  1572.         if (ANSW.b5.isIE || ANSW.b5.isOpera)
  1573.         {
  1574.             if (ANSW.b5.oldcontextmenu)
  1575.                 return ANSW.b5.oldcontextmenu();
  1576.         }
  1577.         return true;
  1578.     }
  1579.     this.onRightClick = onRightClick;
  1580.               /* genere une iframe pour faire passer les divs par dessus des selects sous IE */
  1581.         var ifrlayer = {
  1582.  
  1583.           make:function(obj) {
  1584.               if(!obj) return; obj = (typeof(obj)=="string" ) ? ANSW.doc.getElementById(obj) : obj; if(!obj) return;
  1585.               if( ANSW.doc.getElementById && !obj.iframelayer ) {
  1586.                   if(obj.parentNode && !obj.iframelayer) var ifr = obj.parentNode.insertBefore(ANSW.doc.createElement("iframe" ), obj);
  1587.                   {
  1588.                       ifr.style.zIndex = parseInt(obj.style.zIndex)-1;
  1589.                   }
  1590.                   ifr.src = "javascript:;";
  1591.                   ifr.id="AnswersBalloonIframe";
  1592.                   with(ifr.style) {
  1593.                       filter = "mask()";
  1594.                       position = "absolute";
  1595.                   }
  1596.                   obj.iframelayer = ifr;
  1597.               }
  1598.               if (obj.iframelayer) {
  1599.                   with(obj.iframelayer.style) {
  1600.                       width  =  obj.offsetWidth+"px";
  1601.                       height =  obj.offsetHeight+"px";
  1602.                       visibility = "visible";
  1603.                       backgroundColor="transparent";
  1604.                       border="none";
  1605.                   }
  1606.                  ifrlayer.move(obj) ;
  1607.               }
  1608.           },
  1609.           replace:function(obj) {
  1610.               if(!obj) return; obj = typeof(obj)=="string" ? ANSW.doc.getElementById(obj) : obj; if (!obj) return;
  1611.               if(!obj.iframelayer) {
  1612.                   obj.iframelayer=ANSW.doc.getElementById("AnswersBalloonIframe");
  1613.               }
  1614.               if (obj.iframelayer) {
  1615.                   with(obj.iframelayer.style) {
  1616.                       visibility = "visible";
  1617.                       }
  1618.                   }
  1619.               ifrlayer.move(obj) ;
  1620.           },
  1621.           hide:function(obj) {
  1622.               if(!obj) return; obj = typeof(obj)=="string" ?ANSW.doc.getElementById(obj) : obj; if (!obj) return;
  1623.               if(obj.iframelayer) {
  1624.                   obj.iframelayer.style.visibility="hidden";
  1625.               }
  1626.           },
  1627.           move:function(obj) {
  1628.               if(!obj) return; obj = typeof(obj)=="string" ? ANSW.doc.getElementById(obj) : obj; if (!obj) return;
  1629.               if(obj && obj.iframelayer) {
  1630.                   with(obj.iframelayer.style) {
  1631.                       if (obj.direction && obj.direction.indexOf("N")>-1)
  1632.                            top = obj.offsetTop+ 24 +"px";
  1633.                       else
  1634.                            top = obj.offsetTop+"px";
  1635.                       left =  obj.offsetLeft+"px"
  1636.                   }
  1637.               }
  1638.           },
  1639.           resize:function(obj) {
  1640.             if(!obj) return; obj = typeof(obj)=="string" ? ANSW.doc.getElementById(obj) : obj; if (!obj) return;
  1641.             if(obj && obj.iframelayer) {
  1642.                 with(obj.iframelayer.style) {
  1643.                     width =  obj.offsetWidth+"px";
  1644.                     height = ANSW.doc.getElementById("popup_header") || ANSW.doc.getElementById("AnswersHeader_W")?"345px":"306px";
  1645.                     marginLeft="10px";
  1646.                     marginTop=ANSW.doc.getElementById("popup_header")?"0px":"10px";
  1647.                 }
  1648.             }
  1649.         }
  1650.       };
  1651.     this.ifrlayer=ifrlayer;
  1652.     function SuppressFlash()
  1653.     {
  1654.         var selObjects=document.getElementsByTagName("EMBED");
  1655.         for(var i=0;i<selObjects.length;i++)
  1656.         {
  1657.             if(selObjects[i].balloonMember!='true')
  1658.             {
  1659.                 if(selObjects[i].style.visibility=='visible' || selObjects[i].style.visibility=='')
  1660.                 {
  1661.                     if(ObjectOverlap(ANSW.b5.balloonDIV, selObjects[i]))
  1662.                     {
  1663.                         selObjects[i].baloonHidden=true;
  1664.                         selObjects[i].style.visibility='hidden';
  1665.                     }
  1666.                 }
  1667.             }
  1668.         }
  1669.         selObjects=document.getElementsByTagName("OBJECT");
  1670.         for(var i=0;i<selObjects.length;i++)
  1671.         {
  1672.             if(selObjects[i].balloonMember!='true')
  1673.             {
  1674.                  if(selObjects[i].style.visibility=='visible' || selObjects[i].style.visibility=='')
  1675.                 {
  1676.                     if(ObjectOverlap(ANSW.b5.balloonDIV, selObjects[i]))
  1677.                     {
  1678.                         selObjects[i].baloonHidden=true;
  1679.                         selObjects[i].style.visibility='hidden';
  1680.                     }
  1681.                 }
  1682.             }
  1683.         }
  1684.     }
  1685.     this.SuppressFlash=SuppressFlash;
  1686.     function RestoreFlash()
  1687.     {
  1688.         var selObjects=document.getElementsByTagName("EMBED");
  1689.  
  1690.         for(var i=0;i<selObjects.length;i++)
  1691.         {
  1692.             if(selObjects[i].baloonHidden)
  1693.             {
  1694.                 selObjects[i].style.visibility='visible';
  1695.                 // Mark as ballonhidden
  1696.                 selObjects[i].baloonHidden=false;
  1697.             }
  1698.         }
  1699.         selObjects=document.getElementsByTagName("OBJECT");
  1700.  
  1701.         for(var i=0;i<selObjects.length;i++)
  1702.         {
  1703.             if(selObjects[i].baloonHidden)
  1704.             {
  1705.                 selObjects[i].style.visibility='visible';
  1706.                 // Mark as ballonhidden
  1707.                 selObjects[i].baloonHidden=false;
  1708.             }
  1709.         }
  1710.     }
  1711.     this.RestoreFlash=RestoreFlash;
  1712. };
  1713. ANSW.parseString = function(string){
  1714.     var queryArr = new Array();
  1715.     if (string && string.length>0)
  1716.     {
  1717.         var tmpArr= string.split(";");
  1718.         for (var i=0;i<tmpArr.length ;i++ ){
  1719.             var index = tmpArr[i].indexOf('=');
  1720.             if (index>0)
  1721.             {
  1722.                 queryArr[tmpArr[i].substring(0,index)]=tmpArr[i].substr(index+1);
  1723.             }
  1724.         }
  1725.     }
  1726.     return queryArr;
  1727. }
  1728. ANSW.initValues = function(arrValues){
  1729.     for (var i in arrValues){
  1730.         var j=i;
  1731.         if (i.indexOf("ANSW.")==0){
  1732.             j = i.substr(5);
  1733.         }
  1734.         this[j]=arrValues[i];
  1735.     }
  1736. }
  1737. ANSW.trim = function(string)
  1738. {
  1739.     return string.replace(/^\s+/g, '').replace(/\s+$/g, '');
  1740. };
  1741. if (!ANSW.b5)
  1742. {
  1743.     ANSW.server = "www.answers.com";
  1744.     ANSW.isFirefoxExtension = false;
  1745.     ANSW.b5=new ANSW.Balloon();
  1746.     ANSW.b5.initBalloon({width:490});
  1747.     ANSW.version = "1.0";
  1748.     ANSW.doc= ANSW.isFirefoxExtension ? window.content.document : document;
  1749.     ANSW.scripts = ANSW.doc.getElementsByTagName('script');
  1750.     for (ANSW.index=0;ANSW.index< ANSW.scripts.length;ANSW.index++){
  1751.     ANSW.src=ANSW.scripts.item(ANSW.index).src;
  1752.     if (ANSW.src && (ANSW.src.indexOf("webtip")>-1 || ANSW.src.indexOf("web_answertip.js")>-1 || ANSW.src.indexOf("answ_utils"))>-1)
  1753.         break;
  1754.     }
  1755.     ANSW.script = ANSW.scripts[ANSW.index];
  1756.     ANSW.queryString ="";
  1757.     if (typeof ANSW.script != "undefined" && ANSW.script!=null)
  1758.     {
  1759.          ANSW.queryString = ANSW.script.src.replace(/^[^\?]+\??/,'').replace(/%27/g,"'");
  1760.  
  1761.          if (ANSW.queryString){
  1762.             ANSW.initValues(ANSW.parseString(ANSW.queryString));
  1763.          }
  1764.     }
  1765.     else
  1766.         ANSW.answersURL="http://www.answers.com";
  1767.  
  1768.         if (!ANSW.getJSHost){
  1769.       ANSW.getJSHost=function(){
  1770.         var host=null;
  1771.         var scripts = document.getElementsByTagName('script');
  1772.         var re=/\s*(https?:\/\/[^\/]*)\//;
  1773.         for (var index=0;index<scripts.length;index++){
  1774.             var src=scripts.item(index).src;
  1775.             if (src && (src.indexOf("webtip")>-1 || src.indexOf("web_answertip.js")>-1 || src.indexOf("answ_utils"))>-1)
  1776.                 break;
  1777.         }
  1778.         if (src.match(re))
  1779.             host = RegExp.$1;
  1780.         else
  1781.             host = location.protocol + "//" + location.host;
  1782.         if (host==null || host=="http://site.answers.com")
  1783.             host = "http://www.answers.com";
  1784.         else if (host=="http://site1.answers.com")
  1785.             host = "http://stage1.answers.com";
  1786.         return host;
  1787.       };
  1788.     }
  1789.     if (ANSW.answersURL){
  1790.         ANSW.Balloon.prototype.answersURL = ANSW.Balloon.prototype.JSBalloonPath = ANSW.answersURL;
  1791.         if (ANSW.JSBalloonPath)
  1792.             ANSW.Balloon.prototype.JSBalloonPath = ANSW.JSBalloonPath;
  1793.     } else if (!ANSW.Balloon.prototype.answersURL)
  1794.     {
  1795.         ANSW.host = ANSW.getJSHost();
  1796.         ANSW.Balloon.prototype.answersURL = ANSW.host;
  1797.         if (ANSW.host == "http://www.answers.com")
  1798.             ANSW.Balloon.prototype.JSBalloonPath = "http://site.answers.com";
  1799.         else
  1800.             ANSW.Balloon.prototype.JSBalloonPath = ANSW.host;
  1801.     }
  1802.     ANSW.Balloon.prototype.isOpera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
  1803.     ANSW.Balloon.prototype.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox") != -1);
  1804.     ANSW.Balloon.prototype.isIE = (navigator.userAgent.toLowerCase().indexOf("msie") != -1);
  1805.     ANSW.Balloon.prototype.isIE6 = ANSW.Balloon.prototype.isIE && navigator.appVersion && navigator.appVersion.indexOf("MSIE 6")!=-1;
  1806.     ANSW.Balloon.prototype.balloonDIV=0;
  1807.     if (ANSW.b5.isIE || ANSW.b5.isOpera)
  1808.     {
  1809.         ANSW.b5.oldkeyup = document.onkeyup;
  1810.         document.onkeyup=ANSW.b5.onkeyup;
  1811.         ANSW.b5.oldmousedown = document.onmousedown;
  1812.         document.onmousedown=ANSW.b5.mdown;
  1813.         ANSW.b5.oldmouseup = document.onmouseup;
  1814.         document.onmouseup= ANSW.b5.moveme_onmouseup;
  1815.         ANSW.b5.oldcontextmenu = document.oncontextmenu;
  1816.         document.oncontextmenu=ANSW.b5.onRightClick;
  1817.     }
  1818.     else
  1819.     {
  1820.         if (ANSW.isFirefoxExtension == false)
  1821.         {
  1822.             document.addEventListener("mousedown",ANSW.b5.mdown,false);
  1823.             document.addEventListener("mouseup",ANSW.b5.moveme_onmouseup,false);
  1824.             document.addEventListener("contextmenu",ANSW.b5.onRightClick,true);
  1825.             document.addEventListener("keyup",ANSW.b5.onkeyup,true);
  1826.         }
  1827.     }
  1828.  }
  1829.